Skip to content

fix: correctly sort books with a half-star rating.#672

Merged
mateusz-bak merged 1 commit intomateusz-bak:masterfrom
rmarker:ratingSort
Jul 20, 2025
Merged

fix: correctly sort books with a half-star rating.#672
mateusz-bak merged 1 commit intomateusz-bak:masterfrom
rmarker:ratingSort

Conversation

@rmarker
Copy link
Contributor

@rmarker rmarker commented May 18, 2025

When sorting by rating, books with a rating of a half-star aren't sorted correctly.

This was due to the ratings being converted to strings and those strings used for sorting. A half-star is stored as 5, which means that the string gets sorted as being above anything starting with 4 or less. I.e. anything but a full five stars.

This has been fixed by doing the comparison on the int directly.

When sorting by rating, books with a rating of a half-star aren't sorted
correctly. This was due to the ratings being converted to strings and
those strings used for sorting. A half-star is stored as 5, which means
that the string gets sorted as being above anything starting with 4 or
less. I.e. anything but a full five stars. This has been fixed by doing
the comparison on the int directly.
@rmarker
Copy link
Contributor Author

rmarker commented May 18, 2025

@mateusz-bak, the code style check failed.
I formatted locally, but it said there were no changes.
Looking at the output of the check, it shows that 122 files failed the formatting. This PR only changes 1 file, so I'm wondering if there is an issue with the check that would cause all the other files to be marked as requiring formatting.
Do you know what is going on or if I'm missing something?

@mateusz-bak
Copy link
Owner

Thanks!
I corrected the issue with code style, it is OK.

@mateusz-bak mateusz-bak merged commit 0c905bb into mateusz-bak:master Jul 20, 2025
3 of 4 checks passed
@mateusz-bak mateusz-bak linked an issue Sep 6, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Half-star rated books not correctly ordered

2 participants